﻿using System;
using System.Collections.Generic;

namespace FBGraph
{
    /// <summary>A wrapper for non-paged collections of data that are returned by the Graph API.</summary>
    /// <typeparam name="TItem">The type of item in the collection.</typeparam>
    /// <seealso cref="DictionaryResult{TItem}" />
    /// <seealso cref="PagedResult{TItem}" />
    /// <seealso cref="IdResult" />
    public class ListResult<TItem> : List<TItem>, IFBGraphResult
    {
        #region [ IFBGraphResult Members ]

        /// <summary>Gets or sets a <see cref="Boolean" /> value representing whether the object has been populated.</summary>
        protected virtual Boolean IsReady { get; set; }
        Boolean IFBGraphResult.IsReady
        {
            get { return this.IsReady; }
            set { this.IsReady = value; }
        }

        void IFBGraphResult.UpdateFrom(IFBGraphResult other)
        {
            var that = other as ListResult<TItem>;
            if (that == null) return;
            else
            {
                this.AddRange(that);
            }
        }

        #endregion
    }
}